package modelo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="T_MUNICIPIO")
public class Municipio implements Comparable<Municipio>{
	
	@Id
	@Column(name="COD_MUNICIPIO", unique=true, nullable=false)
	private Integer codigo;
	
	@Column(name="NOM_MUNICIPIO", nullable=false)
	private String nome;
	
	@ManyToOne
	@JoinColumn(name="ID_UF")
	private UF uf;
	
	
	public Municipio(Integer codigo, String nome, UF uf) {
		
		this.codigo = codigo;
		this.nome = nome;
		this.uf = uf;
	}

	public Municipio() {
		this.uf = new UF();
	}

	public Integer getCodigo() {
		return codigo;
	}

	public void setCodigo(Integer codigo) {
		this.codigo = codigo;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public UF getUf() {
		return uf;
	}

	public void setUf(UF uf) {
		this.uf = uf;
	}
	
	@Override
	public String toString() {
	
		return String.valueOf(this.getCodigo());
	}

	@Override
	public int compareTo(Municipio o) {
		// TODO Auto-generated method stub
		return this.getNome().compareToIgnoreCase(o.getNome());
	}
	
	
}
